package com.foreknow.demo5;

public class ObjectArray {


    public static void main(String[] args) {
        Employee s1 = new Employee("1001","1111","2222");
        Employee s2 = new Employee("1002","2222","2222");
        Employee[] arr = new Employee[2];
        //如何向数组中添加元素
        arr[0] = s1;
        arr[1] = s2;
        //如何获取数组中的元素
        Employee a = arr[0];
        System.out.println(a.getName());
        //如何遍历数组
        for(int i = 0;i < arr.length;i++){
            Employee b = arr[i];
            System.out.println(b.getName()+"-"+b.getId()+"-"+b.getDepartment());
        }
    }
}
